﻿#include "Debuger.h"

#pragma warning(disable : 5105)

#ifdef APIENTRY
#undef APIENTRY

#include <windows.h>

#endif




bool Debuger::init()
{
	AllocConsole();
	m_out = freopen("conout$", "w", stdout);
	m_in = freopen("CONIN$", "r", stdin);
	m_err = freopen("CONOUT$", "w", stderr);
	m_handle = GetStdHandle(STD_OUTPUT_HANDLE);
	_wsetlocale(LC_ALL, L"");

	m_isInit = true;

	return true;
}

Debuger::~Debuger()
{
}

Debuger::Debuger()
	:m_err(nullptr)
	, m_in(nullptr)
	, m_out(nullptr)
	, m_isInit(false)
{

}

void Debuger::setErrState()
{
	SetConsoleTextAttribute(reinterpret_cast<HANDLE>(m_handle), FOREGROUND_RED);
}

void Debuger::setInforState()
{
	SetConsoleTextAttribute(reinterpret_cast<HANDLE>(m_handle), FOREGROUND_GREEN);
}

void Debuger::setWarningState()
{
	SetConsoleTextAttribute(reinterpret_cast<HANDLE>(m_handle), FOREGROUND_BLUE);
}

void Debuger::destory()
{
	if (!m_isInit)
	{
		return;
	}

	FreeConsole();
}


